<template>
	<!-- 最新策略 -->
	<view>
		<view class="ceiling" :style="{ 'padding-top': statusBarHeight + 'px' }"></view>
		<uni-nav-bar left-icon="back" title="最新策略" backgroundColor="#EE515A" color="#ffffff" @clickLeft="handleBack"></uni-nav-bar>
		<view class="listWarp flx flx-col" v-for="(item, index) in data" :key="index">
			<view class="items flx flx-col">
				<text class="text-black" style="font-size: 28rpx;">{{item.sname}}（{{item.scode}}）</text>
				<view class="" style="height: 28rpx;"></view>
				<view class="flx flx-bet" style="color: #666666;font-size: 26rpx;">
					<view class="flx flx-col item" style="width: 27%;">
						<text class="title txt">收益率</text>
						<text class="color_EE4343" :class="item.point>0?'up':'down'">{{item.point.toFixed(2)}}%</text>
					</view>
					<view class="flx flx-col flx-bet item" style="width: 33%;">
						<text class="buy txt">买价：{{item.buyMoney}}</text>
						<text class="color_EE4343">盈亏：<span :class="item.point>0?'up':'down'">{{item.profitAndLoss | toFixeds}}</span></text>
					</view>
					<view class="flx flx-col flx-bet item">
						<text class="Sell txt">卖价：{{item.smoney}}</text>
						<text>数量：{{item.snum}}</text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	
	export default {
		data() {
			return {
				data: [],
			}
		},
		filters: {
			toFixeds: function (value) {
				value = Number(value);
				return value.toFixed(2);
			},
			toFixed4: function (value, options) {
				value = Number(value);
				return value.toFixed(4);
			}
		},
		methods: {
			//返回上一级页面
			handleBack() {
				uni.navigateBack({
					delta: 1
				});
			},
			checkLogin() {
				this.$Request.get(this.$api.index.checkLogin).then(res => {
					if (res.code == 1) {
						uni.navigateTo({
							url: "/pages/member/login",
						})
					}
				})
			},
			getNewSell() {
				this.$Request.get(this.$api.index.getNewSell).then(res => {
					this.data = res.data;
				})
			}
		},
		onLoad() {
			this.checkLogin();
			this.getNewSell();
		}
	}
</script>

<style>
	.items{
		padding: 34rpx 42rpx 22rpx 29rpx;
		border-bottom: 1px solid #F2F2F2;
	}
	.txt{
		line-height: 48rpx;
	}
	.down {
		color: #45c74f;
	}
	.up {
		color: red;
	}
</style>
